<template>
  <div class="cate-nav" v-if="Object.keys(categoryTitles).length != 0">
    <scroll class="content" ref="scroll" :probe-type="3" :pull-up-load="true">
    <ul>
      <li
        :key="index"
        v-for="(item, index) in categoryTitles"
        :class="{ active: currentIndex == index }"
        @click="liClick(index, item.maitKey)"
      >
        {{ item.title }}
      </li>
    </ul>
    </scroll>
  </div>
</template>

<script>
import Scroll from "components/common/scroll/Scroll.vue";
export default {
  name: "CategoryNav",
  components: { Scroll },
  props: {
    categoryTitles: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  data() {
    return {
      currentIndex: 0,
    };
  },
  methods: {
    liClick(index, maitKey) {
      this.currentIndex = index;
      this.$emit('itemClick', maitKey);
    },
  },
};
</script>

<style scoped>
.cate-nav {
  background: #f6f6f6;
  width:25vw;
  height: 100vh;
}
.content {
  height: calc(100% - 93px);
  overflow: hidden;
  
}
li {
  list-style: none;
  height: 40px;
  line-height: 40px;
  text-align: center;
}
.active {
  background: #fff;
  color: var(--color-tint);
  font-weight: 700;
  border-left: 3px solid var(--color-tint);
}
</style>
